#include "at.h"

static char send_buf[128];
static u32 last_cmd_len = 0;


#if 1

void at_print_raw_tx(const char *name, const char *buf, uint32_t size)
{
	size = size;
	if (strlen(buf) != 0)
	{
		printf("[AT-T] %s\n", buf);
	}
}

void at_print_raw_rx(const char *name, const char *buf, uint32_t size)
{
	size = size;
	if (strlen(buf) != 0)
	{
		printf("[AT-R] %s", buf);
	}
}

#else

void at_print_raw(const char *name, const char *buf, uint32_t size)
{
#define __is_print(ch)       ((unsigned int)((ch) - ' ') < 127u - ' ')
#define WIDTH_SIZE           32
	u32 i, j;
	
	for(i=0;i<size;i+=WIDTH_SIZE)
	{
		printf("[D/AT] %s: %04X-%04X: ", name, i, i + WIDTH_SIZE);
		for (j = 0; j < WIDTH_SIZE; j++)
		{
			if (i + j < size)
			{
				printf("%02X ", buf[i + j]);
			}
			else
			{
				printf("   ");
			}
			if ((j + 1) % 8 == 0)
			{
				printf(" ");
			}
		}
		
		printf("  ");
        for (j = 0; j < WIDTH_SIZE; j++)
        {
            if (i + j < size)
			{
				printf("%c", __is_print(buf[i + j]) ? buf[i + j] : '.');
			}
		}
		printf("\n");
	}
}

void at_print_raw_tx(const char *name, const char *buf, uint32_t size)
{
	at_print_raw(name, buf, size);
}

void at_print_raw_rx(const char *name, const char *buf, uint32_t size)
{
	at_print_raw(name, buf, size);
}

#endif

char *at_utils_get_last_cmd(u32 *cmd_size)
{
	*cmd_size = last_cmd_len;
	return send_buf;
}





